package com.vint.lintcode;

import com.vint.common.ListNode;

/**
 * 翻转链表，简单
 */
public class Lintcode35 {
	public ListNode reverse(ListNode head) {
		if (null == head || null == head.next) {
			return head;
		}
		ListNode newHead = head;
		ListNode walk = head.next;
		newHead.next = null;
		while (null != walk) {
			ListNode nextWalk = walk.next;
			walk.next = newHead;
			newHead = walk;
			walk = nextWalk;
		}
		return newHead;
	}

}
